/**
 * 是否允许超库存请领
 * @return {boolean}
 */
let isAllowOverApply = () => {
  return global.utils.getBooleanParam('allow_over_apply', true)
}

/**
 * 是否允许零库存请领
 * @return {boolean}
 */
let isAllowZeroApply = () => {
  return global.utils.getBooleanParam('allow_zero_apply', true)
}
/**
 * 是否自动转配送单
 * @return {boolean}
 */
let isAutoChangeDist = () => {
  return global.utils.getBooleanParam('auto_change_dist', false)
}

/**
 * 是否自动转调拨单
 * @return {boolean}
 */
let isAutoChangeTransfer = () => {
  return global.utils.getBooleanParam('auto_change_transfer', false)
}

let isApplyLockStock = () => {
  return global.utils.getBooleanParam('flag_apply_lock', true)
}

/**
 * 供应商入库单是否可以修改
 * @return {boolean}
 */
let isAllowInOrderModify = () => {
  return global.utils.getBooleanParam('allow_in_order_modify', true)
}

/**
 * 供应商入库单是否可以删除
 * @return {boolean}
 */
let isAllowInOrderDelete = () => {
  return global.utils.getBooleanParam('allow_in_order_delete', true)
}
/**
 * 结算单数据筛选字段
 * @return {string}
 */
let systemSettlementField = () => {
  return global.utils.getStringParam('system_settlement_field', null)
}
let systemSettlementFlowValue = () => {
  return global.utils.getStringParam('system_settlement_flow_value', 'end')
}

let allowCloseAfterDelivered = () => {
  return global.utils.getBooleanParam('allow_close_after_delivered', true)
}

let admAuditMax = () => {
  return global.utils.getStringParam('adm_audit_max', '未设置')
}

let allowInternet = () => {
  return global.utils.getBooleanParam('system_allow_internet', true)
}

//his病人消耗单使用ws实时查询窗口 his病人消耗单使用ws实时查询窗口
let hisOprtuseUsewswin = () => {
  return global.utils.getBooleanParam('his_oprtuse_usewswin', true)
}

//耗材是否可以编辑
let matrEditConfigIsEnabled = (fieldName) => {
  let matrEditConfig = global.utils.getStringParam('matr_edit_config', null)
  if (!matrEditConfig) return false
  let matrEditConfigArr = global.utils.str2json(matrEditConfig)
  if (!matrEditConfigArr || matrEditConfigArr.length < 1) return false
  let flagEnabled = false
  matrEditConfigArr.forEach(fieldConfig => {
    if (fieldConfig.pkname == fieldName) {
      flagEnabled = fieldConfig.flagEnabled && fieldConfig.flagEnabled == true
    }
  })
  return flagEnabled
}

//字典类型是否可以修改
let dictEditConfigIsEnabled = (that) => {
  let systemProperties = that.$store.state.dicts.systemProperties
  //参数不存在或者非项目时，可编辑
  if (!systemProperties || !systemProperties.flagProject) return  true
  //项目时，根据系统配置来
  return global.utils.getBooleanParam('dict_edit_config', false)
}

//查询数据视图默认天数配置
let defaultQueryConfig = (viewKey) => {
  let defaultQueryConfig = global.utils.getStringParam('default_query_config', null)
  if (!defaultQueryConfig) return null
  let configArr = global.utils.str2json(defaultQueryConfig)
  if (!configArr || configArr.length < 1) return null
  let configView = null
  configArr.forEach(config => {
    if (config.view_key == viewKey) {
      configView = {
        field: config.config_date,
        days: Number(config.config_days),
      }
      //未配置则默认当天
      if (!configView.days || configView.days < 1) configView.days = 1
    }
  })
  return configView
}

/**
 * 请领是否显示0库存耗材
 * @return {boolean}
 */
let isShowZeroApply = () => {
  return global.utils.getBooleanParam('show_zero_apply', true)
}
/**
 * 允许项目进行设计编辑，编辑数据视图、菜单，1：是，0或不存在为否
 * @return {boolean}
 */
let allowProjectDesign = (that) => {
  let systemProperties = that.$store.state.dicts.systemProperties
  //参数不存在或者非项目时，可编辑
  if (!systemProperties || !systemProperties.flagProject) return  true
  //项目时，根据系统配置来
  return global.utils.getBooleanParam('allow_project_design', false)
}

/**
 * 配送后不提示打开配送单确认框  1：不提示，不存在或者1:不提示
 * @return {boolean}
 */
let isNoapplyDistConfirm = (that) => {
  //项目时，根据系统配置来
  return global.utils.getBooleanParam('is_noapply_dist_confirm', true)
}

/**
 * 医院名称
 * @return
 * @param nullIf 为空时返回
 */
let getSystemHospitalName = (that, nullIf) => {
  return global.utils.getStringParam('system_hospital_name', nullIf)
}

const parameters = {
  isAllowOverApply,
  isAllowZeroApply,
  isAutoChangeDist,
  isAutoChangeTransfer,
  isApplyLockStock,
  isAllowInOrderModify,
  isAllowInOrderDelete,
  systemSettlementField,
  systemSettlementFlowValue,
  allowCloseAfterDelivered,
  admAuditMax,
  allowInternet,
  hisOprtuseUsewswin,
  matrEditConfigIsEnabled,
  isShowZeroApply,
  defaultQueryConfig,
  allowProjectDesign,
  isNoapplyDistConfirm,
  dictEditConfigIsEnabled,
  getSystemHospitalName,
}
export default parameters
